package com.shoulei.designpattern.interpreterPattern;

/**
 * @ClassName:InterpreterPatternDemo
 * @Descrition:
 * @Author:shoulei
 * @Date:2019/4/14 18:02
 * @Verson:
 */
public class InterpreterPatternDemo {
    public static Expression getMaleException(){
        Expression robert = new TerminalExpress("Robert");
        Expression john = new TerminalExpress("John");
        return  new OrExpression(robert,john);
    }
    public static Expression getMarriedWoman(){
        Expression julie=new TerminalExpress("Julie");
        Expression married=new TerminalExpress("Married");
        return new AndExpression(julie,married);
    }

    public static void main(String[] args) {
        Expression isMale = getMaleException();
       // Expression isMarriedWoman=getMarriedWomanExpression();
        System.out.println("John is male? "+isMale.interpret("John"));
     //   System.out.println("Julie is a married women? "+isMarriedWoman.interpret("Married Julie"));

    }
}
